package com.xuxin.pda.fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.blankj.utilcode.util.ActivityUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
import com.xuxin.pda.R;
import com.xuxin.pda.activity.TrashCollectActivity;
import com.xuxin.pda.adapter.MainAdapter;
import com.xuxin.pda.base.BaseFragment;
import com.xuxin.pda.listener.MainListener;
import com.xuxin.pda.utils.RecycleUtils;

import butterknife.BindView;

public class MainFragment extends BaseFragment {
    @BindView(R.id.smart_refresh)
    SmartRefreshLayout smart_refresh;
    @BindView(R.id.smart_recycle)
    RecyclerView smart_recycle;

    public static MainFragment newInstance() {
        return new MainFragment();
    }

    @Override
    public View setContentView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) {
        return inflater.inflate(R.layout.fragment_main, container, false);
    }

    @Override
    public void initView() {
        smart_refresh.setEnableLoadMore(false);
        smart_refresh.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                smart_refresh.finishRefresh();
            }
        });
        RecycleUtils.init(smart_recycle);
        MainAdapter myAdapter = new MainAdapter();
        smart_recycle.setAdapter(myAdapter);
        myAdapter.setOnItemClickListener(new MainListener());
        myAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                if (position == 0) {
                    ActivityUtils.startActivity(TrashCollectActivity.class);
                }
            }
        });
    }

    @Override
    public void initData() {
    }

    @Override
    public void onComplete() {
    }

    @Override
    public void onClick(View view) {
    }
}